
const searchFormList = [
  { label: '', width: '130px', value: 'btnOperation', type: 'slot' },
	{ label: '关键词', value: 'query', type: 'input', width: '200px' },
  { label: '隶属平台', value: 'ostype', type: 'select', width: '200px', option: 'verOsType', filterable: true,  clearable: true},
	{ label: '', width: '200px', value: 'btnSearch', type: 'slot' }
];

const tables = [ // 表格数据
  { label: '记录ID', value: 'id', sort:'custom'},
  { label: '应用编号', value: 'appcode'},
  { label: '版本号[比较]', value: 'version'},
  { label: '版本名称', value: 'vercode'},
  { label: '下载地址', value: 'url', type: 'slot'},
  { label: '隶属平台', value: 'ostype', type: 'slot'},
  { label: '是否生效', value: 'status', type: 'slot'},
  { label: '是否强制升级', value: 'isupdate', type: 'slot'},
  { label: '版本白名单', value: 'filter'},
  { label: '版本备注', value: 'memo', width:240},
  { label: '更新时间', value: 'stime'}
];

const fieldList = [ // 新增弹出数据
  { label: '应用编号', value: 'appcode', type: 'input', width: '300px'},
  { label: '隶属平台', value: 'ostype', type:'select', width: '300px', option: 'verOsType', filterable: true, className:''},
  { label: '下载地址', value: 'url', type: 'input', width: '420px'},
  { label: '版本白名单', value: 'filter', type: 'input', width: '420px'},
  { label: '版本号[比较]', value: 'version', type: 'input', width: '300px'},
  { label: '版本名称', value: 'vercode', type: 'input', width: '300px'},
  { label: '是否强制升级', value: 'isupdate', type:'select', width: '300px', option: 'yesOrNo', filterable: true, className:''},
  { label: '是否生效', value: 'status', type:'select', width: '300px', option: 'yesOrNo', filterable: true, className:''},
  { label: '备注', value: 'memo', type: 'textarea', width: '420px', autosize:{minRows: 6, maxRows: 1000}},
];

const rules = {
	appcode: [{ required: true, message: '请输入应用编号', trigger: 'change' }],
  ostype: [{ required: true, message: '请选择隶属平台', trigger: 'change' }],
	url: [{ required: true, message: '请输入下载地址', trigger: 'change' }],
  version: [{ required: true, message: '请输入数值版本号', trigger: 'change' }],
  vercode: [{ required: true, message: '请输入版本名称', trigger: 'change' }],
  memo: [{ required: true, message: '输入版本更新说明', trigger: 'change' }],
  isupdate: [{ required: true, message: '请选择是否强制更新', trigger: 'change' }],
  status: [{ required: true, message: '请选择是否生效', trigger: 'change' }]
};

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  searchFormList,tables,fieldList,fieldData,rules
};